package com.sunny.example.dynamicschedule;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 合唱队 HJ24
 */
public class DS5 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int totalStudents = Integer.parseInt(scanner.nextLine());
            int[] heights = new int[totalStudents];
            String[] strings = scanner.nextLine().split(" ");
            for (int i = 0; i < heights.length; i++) {
                heights[i] = Integer.parseInt(strings[i]);
            }
            if (heights != null && heights.length > 0) {
                int[][] dp = new int[totalStudents + 1][heights.length + 1];
                for (int k = 1; k <= heights.length; k++) {
                    dp[0][k] = heights[k - 1];
                }
                List<Integer> usedList = new ArrayList<>();

                int iv = 0;
                int prexN = dp[0][0];
                boolean stateChange = false;//是否切换状态
                for (int i = 1; i <= totalStudents; i++) {
                    for (int j = 1; j <= heights.length; j++) {
                        dp[i][j] = heights[j];
                        int curN = heights[j];//当前的值
                        prexN = i>1?dp[i - 1][j - 1]:curN;//前一个的值
                        int endN = heights[j + 1 > totalStudents ? totalStudents : j + 1];
                        //与左上格比较
                        //先比较大于的
                        //状态切换前，是升序
                        if (endN < curN && curN > prexN) {
                            stateChange = true;
                        }
                        if (!stateChange) {
                            if (curN > prexN) {
                                iv = dp[i][j];
                                usedList.add(iv);
                                break;
                            }
                        } else {
                            //状态切换
                            if (curN < prexN) {
                                iv = dp[i][j];
                                usedList.add(iv);
                                break;
                            }
                        }


                    }
                }

                System.out.println(usedList.size());
            }
        }
    }
}
